package cc.w3d.jawos.apps.artiks.client.widgets;

import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.user.client.ui.TreeItem;

public class IconTreeItem extends TreeItem
{
	String text;
	ImageResource icon;

	public IconTreeItem(ImageResource icon, String text)
		{this.icon = icon; this.text = text; fixText();}

	@Override
	public void setText(String text) {this.text = text; fixText();}

	@Override
	public void setHTML(String html) {this.text = html; fixText();}

	@Override
	public String getText() {return text;}

	@Override
	public String getHTML() {return text;}

	public void setIcon(ImageResource icon)
		{this.icon = icon; fixText();}

	public ImageResource getIcon()
		{return icon;}

	private void fixText()
		{super.setHTML("<img style='position:relative; top:4' src='" + icon.getURL() + "' /> " + text);}
}

